package com.gitee.huxing.course.netty.gateway.filter;

import io.netty.buffer.Unpooled;
import io.netty.handler.codec.http.FullHttpResponse;
import lombok.extern.slf4j.Slf4j;

import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;

import static io.netty.handler.codec.http.HttpHeaderNames.CONTENT_LENGTH;

/**
 * @Description: 响应过滤
 * @ProjectName: JavaCourse
 * @Package: com.gitee.huxing.course.netty.gateway.filter
 * @ClassName: HttpHeaderResponseFilter
 * @Author: huxing
 * @DateTime: 2021-08-19 下午12:39
 */
@Slf4j
public class HttpHeaderResponseFilter implements HttpResponseFilter{

    @Override
    public FullHttpResponse filter(FullHttpResponse response){
        // 简单处理报文头增加应答消息时间
        response.headers().set("responseTime", LocalDateTime.now().toString());
        // 返回
        return response;
    }
}
